﻿
@{
    ViewData["Title"] = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}


<script src="~/lib/ueditor/ueditor.config.js"></script>
<script src="~/lib/ueditor/ueditor.all.js"></script>
<script src="~/lib/ueditor/lang/zh-cn/zh-cn.js"></script>
<script src="~/js/VueEditor.js"></script>

<div id="divForm" style="margin:2px;padding:2px;">
    <el-form :model="form" label-width="120px">
        <el-row :gutter="24">
            <el-col :span="12">
                <el-form-item label="公司名称" required>
                    <el-input v-model="form.companyName" placeholder="在此处输入公司名称"></el-input>
                </el-form-item>
            </el-col> 
        </el-row>
        <el-row :gutter="24"> 
            <el-col :span="12">
                <el-form-item label="公司地址" required>
                    <el-input v-model="form.address" placeholder="在此处输入公司地址"></el-input>
                </el-form-item>
            </el-col> 
        </el-row> 
        <el-row :gutter="24">
            <el-col :span="12">
                <el-form-item label="联系方式" required>
                    <el-input v-model="form.contact" placeholder="在此处输入联系方式"></el-input>
                </el-form-item>
            </el-col>
        </el-row> 
        <el-row :gutter="24">
            <el-col :span="12">
                <el-form-item label="公司简介" required>
                    <ue-editor :editorcontent="form.briefIntroduction" v-on:change="changeContent"></ue-editor>
                </el-form-item>
            </el-col>
        </el-row>
        <el-form-item>
            <el-button type="primary" @@click="SaveCompany()" size="mini" v-show="pageButtons.includes('savecompanyintro')">保存</el-button>
            <el-button @@click="Back()" size="mini">关闭</el-button>
        </el-form-item>
    </el-form>
</div>
<script>
    //ueditor.config.js 的serverUrl需要修改配置路径，如果不上传图片或者文件则不需要修改
    var vueCompanyCategory = new Vue({
        el: '#divForm',
        data() {
            return {
                pageButtons: [],
                newsCategoryList:[],
                form: {
                    id: parseInt(getQueryString("id")||0),
                    companyName: "",
                    address: "", 
                    contact: "",
                    briefIntroduction:""
                }
            }
        },
        created() {
            var _this = this;

            _this.GetCompany(); 
            _this.$getMenuButtons();
        },
        methods: { 
            changeContent: function (content) {
                this.form.briefIntroduction = content;
            },
            GetCompany() {
                var _this = this;
                _this.$get("@Url.Action("GetCompanyInfo", "Company")?Id="+_this.form.id ).then((res) => {
                    _this.form = res;
                    _this.defaultcheckedkeys = _this.form.parentId;
                });
            },
            SaveCompany() {
                var _this = this; 
                _this.$post("@Url.Action("SaveCompanyInfo", "Company")", _this.form).then((res) => {
                    _this.$success(res.message, function () {
                      
                    });
                });
            },
            Back() {
                this.$back();
            }
        }
    });
</script>

